
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta charset="utf-8" />
    <title>dis --- Python 字节码反汇编器 &#8212; Python 3.7.8 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.8 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="pickletools --- pickle 开发者工具集" href="pickletools.html" />
    <link rel="prev" title="compileall --- Byte-compile Python libraries" href="compileall.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/dis.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="pickletools.html" title="pickletools --- pickle 开发者工具集"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="compileall.html" title="compileall --- Byte-compile Python libraries"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="language.html" accesskey="U">Python 语言服务</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-dis">
<span id="dis-disassembler-for-python-bytecode"></span><h1><a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> --- Python 字节码反汇编器<a class="headerlink" href="#module-dis" title="永久链接至标题">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.7/Lib/dis.py">Lib/dis.py</a></p>
<hr class="docutils" />
<p><a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> 模块通过反汇编支持CPython的 <a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a> 分析。该模块作为输入的 CPython 字节码在文件 <code class="file docutils literal notranslate"><span class="pre">Include/opcode.h</span></code> 中定义，并由编译器和解释器使用。</p>
<div class="impl-detail compound">
<p class="compound-first"><strong>CPython implementation detail:</strong> 字节码是 CPython 解释器的实现细节。不保证不会在Python版本之间添加、删除或更改字节码。不应考虑将此模块的跨 Python VM 或 Python 版本的使用。</p>
<div class="compound-last versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>每条指令使用2个字节。以前字节数因指令而异。</p>
</div>
</div>
<p>示例：给出函数 <code class="xref py py-func docutils literal notranslate"><span class="pre">myfunc()</span></code>:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">myfunc</span><span class="p">(</span><span class="n">alist</span><span class="p">):</span>
    <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">alist</span><span class="p">)</span>
</pre></div>
</div>
<p>可以使用以下命令显示 <code class="xref py py-func docutils literal notranslate"><span class="pre">myfunc()</span></code> 的反汇编</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dis</span><span class="o">.</span><span class="n">dis</span><span class="p">(</span><span class="n">myfunc</span><span class="p">)</span>
<span class="go">  2           0 LOAD_GLOBAL              0 (len)</span>
<span class="go">              2 LOAD_FAST                0 (alist)</span>
<span class="go">              4 CALL_FUNCTION            1</span>
<span class="go">              6 RETURN_VALUE</span>
</pre></div>
</div>
<p>(&quot;2&quot; 是行号)。</p>
<div class="section" id="bytecode-analysis">
<h2>字节码分析<a class="headerlink" href="#bytecode-analysis" title="永久链接至标题">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.4 新版功能.</span></p>
</div>
<p>字节码分析 API 允许将 Python 代码片段包装在 <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> 对象中，以便轻松访问已编译代码的详细信息。</p>
<dl class="class">
<dt id="dis.Bytecode">
<em class="property">class </em><code class="sig-prename descclassname">dis.</code><code class="sig-name descname">Bytecode</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">*</em>, <em class="sig-param">first_line=None</em>, <em class="sig-param">current_offset=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode" title="永久链接至目标">¶</a></dt>
<dd><p>分析的字节码对应于函数、生成器、异步生成器、协程、方法、源代码字符串或代码对象（由 <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> 返回）。</p>
<p>这是下面列出的许多函数的便利包装，最值得注意的是 <a class="reference internal" href="#dis.get_instructions" title="dis.get_instructions"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_instructions()</span></code></a> ，迭代于 <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> 的实例产生字节码操作 <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> 的实例。</p>
<p>如果 <em>first_line</em> 不是 <code class="docutils literal notranslate"><span class="pre">None</span></code> ，则表示应该为反汇编代码中的第一个源代码行报告的行号。否则，源行信息（如果有的话）直接来自反汇编的代码对象。</p>
<p>如果 <em>current_offset</em> 不是 <code class="docutils literal notranslate"><span class="pre">None</span></code> ，则它指的是反汇编代码中的指令偏移量。设置它意味着 <a class="reference internal" href="#dis.Bytecode.dis" title="dis.Bytecode.dis"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dis()</span></code></a> 将针对指定的操作码显示“当前指令”标记。</p>
<dl class="method">
<dt id="dis.Bytecode.from_traceback">
<em class="property">classmethod </em><code class="sig-name descname">from_traceback</code><span class="sig-paren">(</span><em class="sig-param">tb</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.from_traceback" title="永久链接至目标">¶</a></dt>
<dd><p>从给定回溯构造一个 <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> 实例，设置 <em>current_offset</em> 为异常负责的指令。</p>
</dd></dl>

<dl class="data">
<dt id="dis.Bytecode.codeobj">
<code class="sig-name descname">codeobj</code><a class="headerlink" href="#dis.Bytecode.codeobj" title="永久链接至目标">¶</a></dt>
<dd><p>已编译的代码对象。</p>
</dd></dl>

<dl class="data">
<dt id="dis.Bytecode.first_line">
<code class="sig-name descname">first_line</code><a class="headerlink" href="#dis.Bytecode.first_line" title="永久链接至目标">¶</a></dt>
<dd><p>代码对象的第一个源代码行（如果可用）</p>
</dd></dl>

<dl class="method">
<dt id="dis.Bytecode.dis">
<code class="sig-name descname">dis</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.dis" title="永久链接至目标">¶</a></dt>
<dd><p>返回字节码操作的格式化视图（与 <a class="reference internal" href="#dis.dis" title="dis.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">dis.dis()</span></code></a> 打印相同，但作为多行字符串返回）。</p>
</dd></dl>

<dl class="method">
<dt id="dis.Bytecode.info">
<code class="sig-name descname">info</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.info" title="永久链接至目标">¶</a></dt>
<dd><p>返回带有关于代码对象的详细信息的格式化多行字符串，如 <a class="reference internal" href="#dis.code_info" title="dis.code_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">code_info()</span></code></a> 。</p>
</dd></dl>

<div class="versionchanged">
<p><span class="versionmodified changed">在 3.7 版更改: </span>现在可以处理协程和异步生成器对象。</p>
</div>
</dd></dl>

<p>示例:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">bytecode</span> <span class="o">=</span> <span class="n">dis</span><span class="o">.</span><span class="n">Bytecode</span><span class="p">(</span><span class="n">myfunc</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">instr</span> <span class="ow">in</span> <span class="n">bytecode</span><span class="p">:</span>
<span class="gp">... </span>    <span class="nb">print</span><span class="p">(</span><span class="n">instr</span><span class="o">.</span><span class="n">opname</span><span class="p">)</span>
<span class="gp">...</span>
<span class="go">LOAD_GLOBAL</span>
<span class="go">LOAD_FAST</span>
<span class="go">CALL_FUNCTION</span>
<span class="go">RETURN_VALUE</span>
</pre></div>
</div>
</div>
<div class="section" id="analysis-functions">
<h2>分析函数<a class="headerlink" href="#analysis-functions" title="永久链接至标题">¶</a></h2>
<p><a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> 模块还定义了以下分析函数，它们将输入直接转换为所需的输出。如果只执行单个操作，它们可能很有用，因此中间分析对象没用：</p>
<dl class="function">
<dt id="dis.code_info">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">code_info</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.code_info" title="永久链接至目标">¶</a></dt>
<dd><p>返回格式化的多行字符串，其包含详细代码对象信息的用于被提供的函数、生成器、异步生成器、协程、方法、源代码字符串或代码对象。</p>
<p>请注意，代码信息字符串的确切内容是高度依赖于实现的，它们可能会在Python VM或Python版本中任意更改。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.7 版更改: </span>现在可以处理协程和异步生成器对象。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.show_code">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">show_code</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">*</em>, <em class="sig-param">file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.show_code" title="永久链接至目标">¶</a></dt>
<dd><p>将提供的函数、方法。源代码字符串或代码对象的详细代码对象信息打印到 <em>file</em> （如果未指定 <em>file</em> ，则为 <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> ）。</p>
<p>这是 <code class="docutils literal notranslate"><span class="pre">print(code_info(x),</span> <span class="pre">file=</span> <span class="pre">file)</span></code> 的便捷简写，用于在解释器提示符下进行交互式探索。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.4 版更改: </span>添加 <em>file</em> 参数。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.dis">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">dis</code><span class="sig-paren">(</span><em class="sig-param">x=None</em>, <em class="sig-param">*</em>, <em class="sig-param">file=None</em>, <em class="sig-param">depth=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.dis" title="永久链接至目标">¶</a></dt>
<dd><p>反汇编 <em>x</em> 对象。 <em>x</em> 可以表示模块、类、方法、函数、生成器、异步生成器、协程、代码对象、源代码字符串或原始字节码的字节序列。对于模块，它会反汇编所有功能。对于一个类，它反汇编所有方法（包括类和静态方法）。对于代码对象或原始字节码序列，它每字节码指令打印一行。它还递归地反汇编嵌套代码对象（推导式代码，生成器表达式和嵌套函数，以及用于构建嵌套类的代码）。在被反汇编之前，首先使用 <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> 内置函数将字符串编译为代码对象。如果未提供任何对象，则此函数会反汇编最后一次回溯。</p>
<p>如果提供的话，反汇编将作为文本写入提供的 <em>file</em> 参数，否则写入 <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> 。</p>
<p>递归的最大深度受 <em>depth</em> 限制，除非它是 <code class="docutils literal notranslate"><span class="pre">None</span></code> 。 <code class="docutils literal notranslate"><span class="pre">depth=0</span></code> 表示没有递归。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.4 版更改: </span>添加 <em>file</em> 参数。</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.7 版更改: </span>实现了递归反汇编并添加了 <em>depth</em> 参数。</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.7 版更改: </span>现在可以处理协程和异步生成器对象。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.distb">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">distb</code><span class="sig-paren">(</span><em class="sig-param">tb=None</em>, <em class="sig-param">*</em>, <em class="sig-param">file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.distb" title="永久链接至目标">¶</a></dt>
<dd><p>如果没有传递，则使用最后一个回溯来反汇编回溯的堆栈顶部函数。 指示了导致异常的指令。</p>
<p>如果提供的话，反汇编将作为文本写入提供的 <em>file</em> 参数，否则写入 <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> 。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.4 版更改: </span>添加 <em>file</em> 参数。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.disassemble">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">disassemble</code><span class="sig-paren">(</span><em class="sig-param">code</em>, <em class="sig-param">lasti=-1</em>, <em class="sig-param">*</em>, <em class="sig-param">file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.disassemble" title="永久链接至目标">¶</a></dt>
<dt id="dis.disco">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">disco</code><span class="sig-paren">(</span><em class="sig-param">code</em>, <em class="sig-param">lasti=-1</em>, <em class="sig-param">*</em>, <em class="sig-param">file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.disco" title="永久链接至目标">¶</a></dt>
<dd><p>反汇编代码对象，如果提供了 <em>lasti</em> ，则指示最后一条指令。输出分为以下几列：</p>
<ol class="arabic simple">
<li><p>行号，用于每行的第一条指令</p></li>
<li><p>当前指令，表示为 <code class="docutils literal notranslate"><span class="pre">--&gt;</span></code> ，</p></li>
<li><p>一个标记的指令，用 <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code> 表示，</p></li>
<li><p>指令的地址，</p></li>
<li><p>操作码名称，</p></li>
<li><p>操作参数，和</p></li>
<li><p>括号中的参数解释。</p></li>
</ol>
<p>参数解释识别本地和全局变量名称、常量值、分支目标和比较运算符。</p>
<p>如果提供的话，反汇编将作为文本写入提供的 <em>file</em> 参数，否则写入 <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> 。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.4 版更改: </span>添加 <em>file</em> 参数。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.get_instructions">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">get_instructions</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">*</em>, <em class="sig-param">first_line=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.get_instructions" title="永久链接至目标">¶</a></dt>
<dd><p>在所提供的函数、方法、源代码字符串或代码对象中的指令上返回一个迭代器。</p>
<p>迭代器生成一系列 <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> ，命名为元组，提供所提供代码中每个操作的详细信息。</p>
<p>如果 <em>first_line</em> 不是 <code class="docutils literal notranslate"><span class="pre">None</span></code> ，则表示应该为反汇编代码中的第一个源代码行报告的行号。否则，源行信息（如果有的话）直接来自反汇编的代码对象。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.4 新版功能.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.findlinestarts">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">findlinestarts</code><span class="sig-paren">(</span><em class="sig-param">code</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.findlinestarts" title="永久链接至目标">¶</a></dt>
<dd><p>此生成器函数使用代码对象 <em>code</em> 的 <code class="docutils literal notranslate"><span class="pre">co_firstlineno</span></code> 和 <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> 属性来查找源代码中行开头的偏移量。它们生成为 <code class="docutils literal notranslate"><span class="pre">(offset,</span> <span class="pre">lineno)`</span> <span class="pre">`对。请参阅</span> <span class="pre">:source:`objects/lnotab_notes.txt`</span> <span class="pre">，了解</span> <span class="pre">``co_lnotab</span></code> 格式以及如何解码它。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>行号可能会减少。 以前，他们总是在增加。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="dis.findlabels">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">findlabels</code><span class="sig-paren">(</span><em class="sig-param">code</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.findlabels" title="永久链接至目标">¶</a></dt>
<dd><p>检测作为跳转目标的原始编译后字节码字符串 <em>code</em> 中的所有偏移量，并返回这些偏移量的列表。</p>
</dd></dl>

<dl class="function">
<dt id="dis.stack_effect">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">stack_effect</code><span class="sig-paren">(</span><em class="sig-param">opcode</em><span class="optional">[</span>, <em class="sig-param">oparg</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.stack_effect" title="永久链接至目标">¶</a></dt>
<dd><p>使用参数 <em>oparg</em> 计算 <em>opcode</em> 的堆栈效果。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.4 新版功能.</span></p>
</div>
</dd></dl>

</div>
<div class="section" id="python-bytecode-instructions">
<span id="bytecodes"></span><h2>Python字节码说明<a class="headerlink" href="#python-bytecode-instructions" title="永久链接至标题">¶</a></h2>
<p><a class="reference internal" href="#dis.get_instructions" title="dis.get_instructions"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_instructions()</span></code></a> 函数和 <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> 类提供字节码指令的详细信息的 <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> 实例：</p>
<dl class="class">
<dt id="dis.Instruction">
<em class="property">class </em><code class="sig-prename descclassname">dis.</code><code class="sig-name descname">Instruction</code><a class="headerlink" href="#dis.Instruction" title="永久链接至目标">¶</a></dt>
<dd><p>字节码操作的详细信息</p>
<dl class="data">
<dt id="dis.Instruction.opcode">
<code class="sig-name descname">opcode</code><a class="headerlink" href="#dis.Instruction.opcode" title="永久链接至目标">¶</a></dt>
<dd><p>操作的数字代码，对应于下面列出的操作码值和 <a class="reference internal" href="#opcode-collections"><span class="std std-ref">操作码集合</span></a> 中的字节码值。</p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.opname">
<code class="sig-name descname">opname</code><a class="headerlink" href="#dis.Instruction.opname" title="永久链接至目标">¶</a></dt>
<dd><p>人类可读的操作名称</p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.arg">
<code class="sig-name descname">arg</code><a class="headerlink" href="#dis.Instruction.arg" title="永久链接至目标">¶</a></dt>
<dd><p>操作的数字参数（如果有的话），否则为 <code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.argval">
<code class="sig-name descname">argval</code><a class="headerlink" href="#dis.Instruction.argval" title="永久链接至目标">¶</a></dt>
<dd><p>已解析的 arg 值（如果已知），否则与 arg 相同</p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.argrepr">
<code class="sig-name descname">argrepr</code><a class="headerlink" href="#dis.Instruction.argrepr" title="永久链接至目标">¶</a></dt>
<dd><p>人类可读的操作参数描述</p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.offset">
<code class="sig-name descname">offset</code><a class="headerlink" href="#dis.Instruction.offset" title="永久链接至目标">¶</a></dt>
<dd><p>在字节码序列中启动操作索引</p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.starts_line">
<code class="sig-name descname">starts_line</code><a class="headerlink" href="#dis.Instruction.starts_line" title="永久链接至目标">¶</a></dt>
<dd><p>行由此操作码（如果有）启动，否则为 <code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</dd></dl>

<dl class="data">
<dt id="dis.Instruction.is_jump_target">
<code class="sig-name descname">is_jump_target</code><a class="headerlink" href="#dis.Instruction.is_jump_target" title="永久链接至目标">¶</a></dt>
<dd><p>如果其他代码跳到这里，则为 <code class="docutils literal notranslate"><span class="pre">True</span></code> ，否则为 <code class="docutils literal notranslate"><span class="pre">False</span></code></p>
</dd></dl>

<div class="versionadded">
<p><span class="versionmodified added">3.4 新版功能.</span></p>
</div>
</dd></dl>

<p>Python编译器当前生成以下字节码指令。</p>
<p><strong>一般指令</strong></p>
<dl class="opcode">
<dt id="opcode-NOP">
<code class="sig-name descname">NOP</code><a class="headerlink" href="#opcode-NOP" title="永久链接至目标">¶</a></dt>
<dd><p>什么都不做。 用作字节码优化器的占位符。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-POP_TOP">
<code class="sig-name descname">POP_TOP</code><a class="headerlink" href="#opcode-POP_TOP" title="永久链接至目标">¶</a></dt>
<dd><p>删除堆栈顶部（TOS）项。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-ROT_TWO">
<code class="sig-name descname">ROT_TWO</code><a class="headerlink" href="#opcode-ROT_TWO" title="永久链接至目标">¶</a></dt>
<dd><p>交换两个最顶层的堆栈项。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-ROT_THREE">
<code class="sig-name descname">ROT_THREE</code><a class="headerlink" href="#opcode-ROT_THREE" title="永久链接至目标">¶</a></dt>
<dd><p>将第二个和第三个堆叠项目向上提升一个位置，向上移动到位置三。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DUP_TOP">
<code class="sig-name descname">DUP_TOP</code><a class="headerlink" href="#opcode-DUP_TOP" title="永久链接至目标">¶</a></dt>
<dd><p>复制堆栈顶部的引用。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DUP_TOP_TWO">
<code class="sig-name descname">DUP_TOP_TWO</code><a class="headerlink" href="#opcode-DUP_TOP_TWO" title="永久链接至目标">¶</a></dt>
<dd><p>复制堆栈顶部的两个引用，使它们保持相同的顺序。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
</dd></dl>

<p><strong>一元操作</strong></p>
<p>一元操作获取堆栈顶部元素，应用操作，并将结果推回堆栈。</p>
<dl class="opcode">
<dt id="opcode-UNARY_POSITIVE">
<code class="sig-name descname">UNARY_POSITIVE</code><a class="headerlink" href="#opcode-UNARY_POSITIVE" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">+TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-UNARY_NEGATIVE">
<code class="sig-name descname">UNARY_NEGATIVE</code><a class="headerlink" href="#opcode-UNARY_NEGATIVE" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">-TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-UNARY_NOT">
<code class="sig-name descname">UNARY_NOT</code><a class="headerlink" href="#opcode-UNARY_NOT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">not</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-UNARY_INVERT">
<code class="sig-name descname">UNARY_INVERT</code><a class="headerlink" href="#opcode-UNARY_INVERT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">~TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-GET_ITER">
<code class="sig-name descname">GET_ITER</code><a class="headerlink" href="#opcode-GET_ITER" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">iter(TOS)</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-GET_YIELD_FROM_ITER">
<code class="sig-name descname">GET_YIELD_FROM_ITER</code><a class="headerlink" href="#opcode-GET_YIELD_FROM_ITER" title="永久链接至目标">¶</a></dt>
<dd><p>如果 <code class="docutils literal notranslate"><span class="pre">TOS</span></code> 是一个 <a class="reference internal" href="../glossary.html#term-generator-iterator"><span class="xref std std-term">generator iterator</span></a> 或 <a class="reference internal" href="../glossary.html#term-coroutine"><span class="xref std std-term">coroutine</span></a> 对象则保持原样。否则实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">iter(TOS)</span></code> 。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<p><strong>二元操作</strong></p>
<p>二元操作从堆栈中删除堆栈顶部（TOS）和第二个最顶层堆栈项（TOS1）。 它们执行操作，并将结果放回堆栈。</p>
<dl class="opcode">
<dt id="opcode-BINARY_POWER">
<code class="sig-name descname">BINARY_POWER</code><a class="headerlink" href="#opcode-BINARY_POWER" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">**</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_MULTIPLY">
<code class="sig-name descname">BINARY_MULTIPLY</code><a class="headerlink" href="#opcode-BINARY_MULTIPLY" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">*</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_MATRIX_MULTIPLY">
<code class="sig-name descname">BINARY_MATRIX_MULTIPLY</code><a class="headerlink" href="#opcode-BINARY_MATRIX_MULTIPLY" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&#64;</span> <span class="pre">TOS</span></code> 。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_FLOOR_DIVIDE">
<code class="sig-name descname">BINARY_FLOOR_DIVIDE</code><a class="headerlink" href="#opcode-BINARY_FLOOR_DIVIDE" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">//</span> <span class="pre">TOS</span></code>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_TRUE_DIVIDE">
<code class="sig-name descname">BINARY_TRUE_DIVIDE</code><a class="headerlink" href="#opcode-BINARY_TRUE_DIVIDE" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">/</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_MODULO">
<code class="sig-name descname">BINARY_MODULO</code><a class="headerlink" href="#opcode-BINARY_MODULO" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">%</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_ADD">
<code class="sig-name descname">BINARY_ADD</code><a class="headerlink" href="#opcode-BINARY_ADD" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">+</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_SUBTRACT">
<code class="sig-name descname">BINARY_SUBTRACT</code><a class="headerlink" href="#opcode-BINARY_SUBTRACT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">-</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_SUBSCR">
<code class="sig-name descname">BINARY_SUBSCR</code><a class="headerlink" href="#opcode-BINARY_SUBSCR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1[TOS]</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_LSHIFT">
<code class="sig-name descname">BINARY_LSHIFT</code><a class="headerlink" href="#opcode-BINARY_LSHIFT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&lt;&lt;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_RSHIFT">
<code class="sig-name descname">BINARY_RSHIFT</code><a class="headerlink" href="#opcode-BINARY_RSHIFT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&gt;&gt;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_AND">
<code class="sig-name descname">BINARY_AND</code><a class="headerlink" href="#opcode-BINARY_AND" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&amp;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_XOR">
<code class="sig-name descname">BINARY_XOR</code><a class="headerlink" href="#opcode-BINARY_XOR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">^</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BINARY_OR">
<code class="sig-name descname">BINARY_OR</code><a class="headerlink" href="#opcode-BINARY_OR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">|</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<p><strong>就地操作</strong></p>
<p>就地操作就像二元操作，因为它们删除了TOS和TOS1，并将结果推回到堆栈上，但是当TOS1支持它时，操作就地完成，并且产生的TOS可能是（但不一定） 原来的TOS1。</p>
<dl class="opcode">
<dt id="opcode-INPLACE_POWER">
<code class="sig-name descname">INPLACE_POWER</code><a class="headerlink" href="#opcode-INPLACE_POWER" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">**</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_MULTIPLY">
<code class="sig-name descname">INPLACE_MULTIPLY</code><a class="headerlink" href="#opcode-INPLACE_MULTIPLY" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">*</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_MATRIX_MULTIPLY">
<code class="sig-name descname">INPLACE_MATRIX_MULTIPLY</code><a class="headerlink" href="#opcode-INPLACE_MATRIX_MULTIPLY" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&#64;</span> <span class="pre">TOS</span></code> 。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_FLOOR_DIVIDE">
<code class="sig-name descname">INPLACE_FLOOR_DIVIDE</code><a class="headerlink" href="#opcode-INPLACE_FLOOR_DIVIDE" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">//</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_TRUE_DIVIDE">
<code class="sig-name descname">INPLACE_TRUE_DIVIDE</code><a class="headerlink" href="#opcode-INPLACE_TRUE_DIVIDE" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">/</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_MODULO">
<code class="sig-name descname">INPLACE_MODULO</code><a class="headerlink" href="#opcode-INPLACE_MODULO" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">%</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_ADD">
<code class="sig-name descname">INPLACE_ADD</code><a class="headerlink" href="#opcode-INPLACE_ADD" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">+</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_SUBTRACT">
<code class="sig-name descname">INPLACE_SUBTRACT</code><a class="headerlink" href="#opcode-INPLACE_SUBTRACT" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">-</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_LSHIFT">
<code class="sig-name descname">INPLACE_LSHIFT</code><a class="headerlink" href="#opcode-INPLACE_LSHIFT" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&lt;&lt;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_RSHIFT">
<code class="sig-name descname">INPLACE_RSHIFT</code><a class="headerlink" href="#opcode-INPLACE_RSHIFT" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&gt;&gt;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_AND">
<code class="sig-name descname">INPLACE_AND</code><a class="headerlink" href="#opcode-INPLACE_AND" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&amp;</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_XOR">
<code class="sig-name descname">INPLACE_XOR</code><a class="headerlink" href="#opcode-INPLACE_XOR" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">^</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-INPLACE_OR">
<code class="sig-name descname">INPLACE_OR</code><a class="headerlink" href="#opcode-INPLACE_OR" title="永久链接至目标">¶</a></dt>
<dd><p>就地实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">|</span> <span class="pre">TOS</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-STORE_SUBSCR">
<code class="sig-name descname">STORE_SUBSCR</code><a class="headerlink" href="#opcode-STORE_SUBSCR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS1[TOS]</span> <span class="pre">=</span> <span class="pre">TOS2</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_SUBSCR">
<code class="sig-name descname">DELETE_SUBSCR</code><a class="headerlink" href="#opcode-DELETE_SUBSCR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">TOS1[TOS]</span></code> 。</p>
</dd></dl>

<p><strong>协程操作码</strong></p>
<dl class="opcode">
<dt id="opcode-GET_AWAITABLE">
<code class="sig-name descname">GET_AWAITABLE</code><a class="headerlink" href="#opcode-GET_AWAITABLE" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">get_awaitable(TOS)</span></code> ，其中 <code class="docutils literal notranslate"><span class="pre">get_awaitable(o)</span></code> 返回 <code class="docutils literal notranslate"><span class="pre">o</span></code> 如果 <code class="docutils literal notranslate"><span class="pre">o</span></code> 是一个有 CO_ITERABLE_COROUTINE 标志的协程对象或生成器对象，否则解析 <code class="docutils literal notranslate"><span class="pre">o.__await__</span></code> 。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-GET_AITER">
<code class="sig-name descname">GET_AITER</code><a class="headerlink" href="#opcode-GET_AITER" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS.__aiter__()</span></code> 。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.7 版更改: </span>已经不再支持从 <code class="docutils literal notranslate"><span class="pre">__aiter__</span></code> 返回可等待对象。</p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-GET_ANEXT">
<code class="sig-name descname">GET_ANEXT</code><a class="headerlink" href="#opcode-GET_ANEXT" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">PUSH(get_awaitable(TOS.__anext__()))</span></code> 。参见 <code class="docutils literal notranslate"><span class="pre">GET_AWAITABLE</span></code> 获取更多 <code class="docutils literal notranslate"><span class="pre">get_awaitable</span></code> 的细节</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BEFORE_ASYNC_WITH">
<code class="sig-name descname">BEFORE_ASYNC_WITH</code><a class="headerlink" href="#opcode-BEFORE_ASYNC_WITH" title="永久链接至目标">¶</a></dt>
<dd><p>从栈顶元素解析 <code class="docutils literal notranslate"><span class="pre">__aenter__</span></code> 和 <code class="docutils literal notranslate"><span class="pre">__aexit__</span></code> 。将 <code class="docutils literal notranslate"><span class="pre">__aexit__</span></code> 和 <code class="docutils literal notranslate"><span class="pre">__aenter__()</span></code> 的结果推入堆栈。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_ASYNC_WITH">
<code class="sig-name descname">SETUP_ASYNC_WITH</code><a class="headerlink" href="#opcode-SETUP_ASYNC_WITH" title="永久链接至目标">¶</a></dt>
<dd><p>创建一个新的帧对象。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<p><strong>其他操作码</strong></p>
<dl class="opcode">
<dt id="opcode-PRINT_EXPR">
<code class="sig-name descname">PRINT_EXPR</code><a class="headerlink" href="#opcode-PRINT_EXPR" title="永久链接至目标">¶</a></dt>
<dd><p>实现交互模式的表达式语句。TOS从堆栈中被移除并打印。在非交互模式下，表达式语句以 <a class="reference internal" href="#opcode-POP_TOP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">POP_TOP</span></code></a> 终止。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BREAK_LOOP">
<code class="sig-name descname">BREAK_LOOP</code><a class="headerlink" href="#opcode-BREAK_LOOP" title="永久链接至目标">¶</a></dt>
<dd><p>Terminates a loop due to a <a class="reference internal" href="../reference/simple_stmts.html#break"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">break</span></code></a> statement.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-CONTINUE_LOOP">
<code class="sig-name descname">CONTINUE_LOOP</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CONTINUE_LOOP" title="永久链接至目标">¶</a></dt>
<dd><p>Continues a loop due to a <a class="reference internal" href="../reference/simple_stmts.html#continue"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">continue</span></code></a> statement.  <em>target</em> is the
address to jump to (which should be a <a class="reference internal" href="#opcode-FOR_ITER"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">FOR_ITER</span></code></a> instruction).</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SET_ADD">
<code class="sig-name descname">SET_ADD</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SET_ADD" title="永久链接至目标">¶</a></dt>
<dd><p>调用 <code class="docutils literal notranslate"><span class="pre">set.add(TOS1[-i],</span> <span class="pre">TOS)</span></code> 。 用于实现集合推导。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LIST_APPEND">
<code class="sig-name descname">LIST_APPEND</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LIST_APPEND" title="永久链接至目标">¶</a></dt>
<dd><p>调用 <code class="docutils literal notranslate"><span class="pre">list.append(TOS[-i],</span> <span class="pre">TOS)</span></code> 。 用于实现列表推导。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-MAP_ADD">
<code class="sig-name descname">MAP_ADD</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-MAP_ADD" title="永久链接至目标">¶</a></dt>
<dd><p>Calls <code class="docutils literal notranslate"><span class="pre">dict.setitem(TOS1[-i],</span> <span class="pre">TOS,</span> <span class="pre">TOS1)</span></code>.  Used to implement dict
comprehensions.</p>
<div class="versionadded">
<p><span class="versionmodified added">3.1 新版功能.</span></p>
</div>
</dd></dl>

<p>对于所有 <a class="reference internal" href="#opcode-SET_ADD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">SET_ADD</span></code></a> 、 <a class="reference internal" href="#opcode-LIST_APPEND"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LIST_APPEND</span></code></a> 和 <a class="reference internal" href="#opcode-MAP_ADD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">MAP_ADD</span></code></a> 指令，当弹出添加的值或键值对时，容器对象保留在堆栈上，以便它可用于循环的进一步迭代。</p>
<dl class="opcode">
<dt id="opcode-RETURN_VALUE">
<code class="sig-name descname">RETURN_VALUE</code><a class="headerlink" href="#opcode-RETURN_VALUE" title="永久链接至目标">¶</a></dt>
<dd><p>返回 TOS 到函数的调用者。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-YIELD_VALUE">
<code class="sig-name descname">YIELD_VALUE</code><a class="headerlink" href="#opcode-YIELD_VALUE" title="永久链接至目标">¶</a></dt>
<dd><p>弹出 TOS 并从一个 <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a> 生成它。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-YIELD_FROM">
<code class="sig-name descname">YIELD_FROM</code><a class="headerlink" href="#opcode-YIELD_FROM" title="永久链接至目标">¶</a></dt>
<dd><p>弹出 TOS 并将其委托给它作为 <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a> 的子迭代器。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.3 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_ANNOTATIONS">
<code class="sig-name descname">SETUP_ANNOTATIONS</code><a class="headerlink" href="#opcode-SETUP_ANNOTATIONS" title="永久链接至目标">¶</a></dt>
<dd><p>检查 <code class="docutils literal notranslate"><span class="pre">__annotations__</span></code> 是否在 <code class="docutils literal notranslate"><span class="pre">locals()</span></code> 中定义，如果没有，它被设置为空 <code class="docutils literal notranslate"><span class="pre">dict</span></code> 。只有在类或模块体静态地包含 <a class="reference internal" href="../glossary.html#term-variable-annotation"><span class="xref std std-term">variable annotations</span></a> 时才会发出此操作码。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-IMPORT_STAR">
<code class="sig-name descname">IMPORT_STAR</code><a class="headerlink" href="#opcode-IMPORT_STAR" title="永久链接至目标">¶</a></dt>
<dd><p>将所有不以 <code class="docutils literal notranslate"><span class="pre">'_'</span></code> 开头的符号直接从模块 TOS 加载到本地名称空间。加载所有名称后弹出该模块。这个操作码实现了 <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">module</span> <span class="pre">import</span> <span class="pre">*</span></code> 。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-POP_BLOCK">
<code class="sig-name descname">POP_BLOCK</code><a class="headerlink" href="#opcode-POP_BLOCK" title="永久链接至目标">¶</a></dt>
<dd><p>Removes one block from the block stack.  Per frame, there is a stack of
blocks, denoting nested loops, try statements, and such.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-POP_EXCEPT">
<code class="sig-name descname">POP_EXCEPT</code><a class="headerlink" href="#opcode-POP_EXCEPT" title="永久链接至目标">¶</a></dt>
<dd><p>从块堆栈中删除一个块。 弹出的块必须是异常处理程序块，在进入 except 处理程序时隐式创建。除了从帧堆栈弹出无关值之外，最后三个弹出值还用于恢复异常状态。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-END_FINALLY">
<code class="sig-name descname">END_FINALLY</code><a class="headerlink" href="#opcode-END_FINALLY" title="永久链接至目标">¶</a></dt>
<dd><p>Terminates a <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> clause.  The interpreter recalls whether the
exception has to be re-raised, or whether the function returns, and continues
with the outer-next block.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_BUILD_CLASS">
<code class="sig-name descname">LOAD_BUILD_CLASS</code><a class="headerlink" href="#opcode-LOAD_BUILD_CLASS" title="永久链接至目标">¶</a></dt>
<dd><p>将 <code class="xref py py-func docutils literal notranslate"><span class="pre">builtins</span> <span class="pre">.__</span> <span class="pre">build_class__()</span></code> 推到堆栈上。它之后被 <a class="reference internal" href="#opcode-CALL_FUNCTION"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_FUNCTION</span></code></a> 调用来构造一个类。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_WITH">
<code class="sig-name descname">SETUP_WITH</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SETUP_WITH" title="永久链接至目标">¶</a></dt>
<dd><p>This opcode performs several operations before a with block starts.  First,
it loads <a class="reference internal" href="../reference/datamodel.html#object.__exit__" title="object.__exit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code></a> from the context manager and pushes it onto
the stack for later use by <code class="xref std std-opcode docutils literal notranslate"><span class="pre">WITH_CLEANUP</span></code>.  Then,
<a class="reference internal" href="../reference/datamodel.html#object.__enter__" title="object.__enter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__enter__()</span></code></a> is called, and a finally block pointing to <em>delta</em>
is pushed.  Finally, the result of calling the enter method is pushed onto
the stack.  The next opcode will either ignore it (<a class="reference internal" href="#opcode-POP_TOP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">POP_TOP</span></code></a>), or
store it in (a) variable(s) (<a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a>, <a class="reference internal" href="#opcode-STORE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_NAME</span></code></a>, or
<a class="reference internal" href="#opcode-UNPACK_SEQUENCE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">UNPACK_SEQUENCE</span></code></a>).</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-WITH_CLEANUP_START">
<code class="sig-name descname">WITH_CLEANUP_START</code><a class="headerlink" href="#opcode-WITH_CLEANUP_START" title="永久链接至目标">¶</a></dt>
<dd><p>Cleans up the stack when a <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement block exits.  TOS is the
context manager's <a class="reference internal" href="../reference/datamodel.html#object.__exit__" title="object.__exit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code></a> bound method. Below TOS are 1--3 values
indicating how/why the finally clause was entered:</p>
<ul class="simple">
<li><p>SECOND = <code class="docutils literal notranslate"><span class="pre">None</span></code></p></li>
<li><p>(SECOND, THIRD) = (<code class="docutils literal notranslate"><span class="pre">WHY_{RETURN,CONTINUE}</span></code>), retval</p></li>
<li><p>SECOND = <code class="docutils literal notranslate"><span class="pre">WHY_*</span></code>; no retval below it</p></li>
<li><p>(SECOND, THIRD, FOURTH) = exc_info()</p></li>
</ul>
<p>In the last case, <code class="docutils literal notranslate"><span class="pre">TOS(SECOND,</span> <span class="pre">THIRD,</span> <span class="pre">FOURTH)</span></code> is called, otherwise
<code class="docutils literal notranslate"><span class="pre">TOS(None,</span> <span class="pre">None,</span> <span class="pre">None)</span></code>.  Pushes SECOND and result of the call
to the stack.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-WITH_CLEANUP_FINISH">
<code class="sig-name descname">WITH_CLEANUP_FINISH</code><a class="headerlink" href="#opcode-WITH_CLEANUP_FINISH" title="永久链接至目标">¶</a></dt>
<dd><p>Pops exception type and result of 'exit' function call from the stack.</p>
<p>If the stack represents an exception, <em>and</em> the function call returns a
'true' value, this information is &quot;zapped&quot; and replaced with a single
<code class="docutils literal notranslate"><span class="pre">WHY_SILENCED</span></code> to prevent <a class="reference internal" href="#opcode-END_FINALLY"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">END_FINALLY</span></code></a> from re-raising the
exception.  (But non-local gotos will still be resumed.)</p>
</dd></dl>

<p>以下所有操作码均使用其参数。</p>
<dl class="opcode">
<dt id="opcode-STORE_NAME">
<code class="sig-name descname">STORE_NAME</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_NAME" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">name</span> <span class="pre">=</span> <span class="pre">TOS</span></code>。 <em>namei</em> 是 <em>name</em> 在代码对象的 <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> 属性中的索引。 在可能的情况下，编译器会尝试使用 <a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a> 或 <a class="reference internal" href="#opcode-STORE_GLOBAL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_GLOBAL</span></code></a>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_NAME">
<code class="sig-name descname">DELETE_NAME</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_NAME" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">name</span></code> ，其中 <em>namei</em> 是代码对象的 <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> 属性的索引。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-UNPACK_SEQUENCE">
<code class="sig-name descname">UNPACK_SEQUENCE</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-UNPACK_SEQUENCE" title="永久链接至目标">¶</a></dt>
<dd><p>将 TOS 解包为 <em>count</em> 个单独的值，它们将按从右至左的顺序被放入堆栈。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-UNPACK_EX">
<code class="sig-name descname">UNPACK_EX</code><span class="sig-paren">(</span><em class="sig-param">counts</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-UNPACK_EX" title="永久链接至目标">¶</a></dt>
<dd><p>实现使用带星号的目标进行赋值：将 TOS 中的可迭代对象解包为单独的值，其中值的总数可以小于可迭代对象中的项数：新值之一将是由所有剩余项构成的列表。</p>
<p><em>counts</em> 的低字节是列表值之前的值的数量，<em>counts</em> 中的高字节则是之后的值的数量。 结果值会按从右至左的顺序入栈。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-STORE_ATTR">
<code class="sig-name descname">STORE_ATTR</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_ATTR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">TOS.name</span> <span class="pre">=</span> <span class="pre">TOS1</span></code>，其中 <em>namei</em> 是 name 在 <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> 中的索引号。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_ATTR">
<code class="sig-name descname">DELETE_ATTR</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_ATTR" title="永久链接至目标">¶</a></dt>
<dd><p>实现 <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">TOS.name</span></code>，使用 <em>namei</em> 作为 <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> 中的索引号。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-STORE_GLOBAL">
<code class="sig-name descname">STORE_GLOBAL</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_GLOBAL" title="永久链接至目标">¶</a></dt>
<dd><p>类似于 <a class="reference internal" href="#opcode-STORE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_NAME</span></code></a> 但会将 name 存储为全局变量。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_GLOBAL">
<code class="sig-name descname">DELETE_GLOBAL</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_GLOBAL" title="永久链接至目标">¶</a></dt>
<dd><p>类似于 <a class="reference internal" href="#opcode-DELETE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">DELETE_NAME</span></code></a> 但会删除一个全局变量。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_CONST">
<code class="sig-name descname">LOAD_CONST</code><span class="sig-paren">(</span><em class="sig-param">consti</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_CONST" title="永久链接至目标">¶</a></dt>
<dd><p>将 <code class="docutils literal notranslate"><span class="pre">co_consts[consti]</span></code> 推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_NAME">
<code class="sig-name descname">LOAD_NAME</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_NAME" title="永久链接至目标">¶</a></dt>
<dd><p>将与 <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code> 相关联的值推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_TUPLE">
<code class="sig-name descname">BUILD_TUPLE</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_TUPLE" title="永久链接至目标">¶</a></dt>
<dd><p>创建一个使用了来自栈的 <em>count</em> 个项的元组，并将结果元组推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_LIST">
<code class="sig-name descname">BUILD_LIST</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_LIST" title="永久链接至目标">¶</a></dt>
<dd><p>类似于 <a class="reference internal" href="#opcode-BUILD_TUPLE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE</span></code></a> 但会创建一个列表。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_SET">
<code class="sig-name descname">BUILD_SET</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_SET" title="永久链接至目标">¶</a></dt>
<dd><p>类似于 <a class="reference internal" href="#opcode-BUILD_TUPLE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE</span></code></a> 但会创建一个集合。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_MAP">
<code class="sig-name descname">BUILD_MAP</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_MAP" title="永久链接至目标">¶</a></dt>
<dd><p>将一个新字典对象推入栈顶。 弹出 <code class="docutils literal notranslate"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">count</span></code> 项使得字典包含 <em>count</em> 个条目: <code class="docutils literal notranslate"><span class="pre">{...,</span> <span class="pre">TOS3:</span> <span class="pre">TOS2,</span> <span class="pre">TOS1:</span> <span class="pre">TOS}</span></code>。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.5 版更改: </span>字典是根据栈中的项创建而不是创建一个预设大小包含 <em>count</em> 项的空字典。</p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_CONST_KEY_MAP">
<code class="sig-name descname">BUILD_CONST_KEY_MAP</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_CONST_KEY_MAP" title="永久链接至目标">¶</a></dt>
<dd><p><a class="reference internal" href="#opcode-BUILD_MAP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_MAP</span></code></a> 版本专用于常量键。 弹出的栈顶元素包含一个由键构成的元组，然后从 <code class="docutils literal notranslate"><span class="pre">TOS1</span></code> 开始从构建字典的值中弹出 <em>count</em> 个值。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_STRING">
<code class="sig-name descname">BUILD_STRING</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_STRING" title="永久链接至目标">¶</a></dt>
<dd><p>拼接 <em>count</em> 个来自栈的字符串并将结果字符串推入栈顶。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_TUPLE_UNPACK">
<code class="sig-name descname">BUILD_TUPLE_UNPACK</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_TUPLE_UNPACK" title="永久链接至目标">¶</a></dt>
<dd><p>从栈中弹出 <em>count</em> 个可迭代对象，将它们合并为单个元组，并将结果推入栈顶。 实现可迭代对象解包为元组形式 <code class="docutils literal notranslate"><span class="pre">(*x,</span> <span class="pre">*y,</span> <span class="pre">*z)</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_TUPLE_UNPACK_WITH_CALL">
<code class="sig-name descname">BUILD_TUPLE_UNPACK_WITH_CALL</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_TUPLE_UNPACK_WITH_CALL" title="永久链接至目标">¶</a></dt>
<dd><p>这类似于 <a class="reference internal" href="#opcode-BUILD_TUPLE_UNPACK"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE_UNPACK</span></code></a> 但专用于 <code class="docutils literal notranslate"><span class="pre">f(*x,</span> <span class="pre">*y,</span> <span class="pre">*z)</span></code> 调用语法。 栈中 <code class="docutils literal notranslate"><span class="pre">count</span> <span class="pre">+</span> <span class="pre">1</span></code> 位置上的项应当是相应的可调用对象 <code class="docutils literal notranslate"><span class="pre">f</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_LIST_UNPACK">
<code class="sig-name descname">BUILD_LIST_UNPACK</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_LIST_UNPACK" title="永久链接至目标">¶</a></dt>
<dd><p>这类似于 <a class="reference internal" href="#opcode-BUILD_TUPLE_UNPACK"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE_UNPACK</span></code></a> 但会将一个列表而非元组推入栈顶。 实现可迭代对象解包为列表形式 <code class="docutils literal notranslate"><span class="pre">[*x,</span> <span class="pre">*y,</span> <span class="pre">*z]</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_SET_UNPACK">
<code class="sig-name descname">BUILD_SET_UNPACK</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_SET_UNPACK" title="永久链接至目标">¶</a></dt>
<dd><p>这类似于 <a class="reference internal" href="#opcode-BUILD_TUPLE_UNPACK"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE_UNPACK</span></code></a> 但会将一个集合而非元组推入栈顶。 实现可迭代对象解包为集合形式 <code class="docutils literal notranslate"><span class="pre">{*x,</span> <span class="pre">*y,</span> <span class="pre">*z}</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_MAP_UNPACK">
<code class="sig-name descname">BUILD_MAP_UNPACK</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_MAP_UNPACK" title="永久链接至目标">¶</a></dt>
<dd><p>从栈中弹出 <em>count</em> 个映射对象，将它们合并为单个字典，并将结果推入栈顶。 实现字典解包为字典形式 <code class="docutils literal notranslate"><span class="pre">{**x,</span> <span class="pre">**y,</span> <span class="pre">**z}</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_MAP_UNPACK_WITH_CALL">
<code class="sig-name descname">BUILD_MAP_UNPACK_WITH_CALL</code><span class="sig-paren">(</span><em class="sig-param">count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_MAP_UNPACK_WITH_CALL" title="永久链接至目标">¶</a></dt>
<dd><p>这类似于 <a class="reference internal" href="#opcode-BUILD_MAP_UNPACK"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_MAP_UNPACK</span></code></a> 但专用于 <code class="docutils literal notranslate"><span class="pre">f(**x,</span> <span class="pre">**y,</span> <span class="pre">**z)</span></code> 调用语法。 栈中 <code class="docutils literal notranslate"><span class="pre">count</span> <span class="pre">+</span> <span class="pre">2</span></code> 位置上的项应当是相应的可调用对象 <code class="docutils literal notranslate"><span class="pre">f</span></code>。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.5 新版功能.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>可迭代对象的位置的确定方式是将操作码参数加 2 而不是将其编码到参数的第二个字节。</p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_ATTR">
<code class="sig-name descname">LOAD_ATTR</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_ATTR" title="永久链接至目标">¶</a></dt>
<dd><p>将 TOS 替换为 <code class="docutils literal notranslate"><span class="pre">getattr(TOS,</span> <span class="pre">co_names[namei])</span></code>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-COMPARE_OP">
<code class="sig-name descname">COMPARE_OP</code><span class="sig-paren">(</span><em class="sig-param">opname</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-COMPARE_OP" title="永久链接至目标">¶</a></dt>
<dd><p>执行布尔运算操作。 操作名称可在 <code class="docutils literal notranslate"><span class="pre">cmp_op[opname]</span></code> 中找到。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-IMPORT_NAME">
<code class="sig-name descname">IMPORT_NAME</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-IMPORT_NAME" title="永久链接至目标">¶</a></dt>
<dd><p>导入模块 <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code>。 会弹出 TOS 和 TOS1 以提供 <em>fromlist</em> 和 <em>level</em> 参数给 <a class="reference internal" href="functions.html#__import__" title="__import__"><code class="xref py py-func docutils literal notranslate"><span class="pre">__import__()</span></code></a>。 模块对象会被推入栈顶。 当前命名空间不受影响：对于一条标准 import 语句，会执行后续的 <a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a> 指令来修改命名空间。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-IMPORT_FROM">
<code class="sig-name descname">IMPORT_FROM</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-IMPORT_FROM" title="永久链接至目标">¶</a></dt>
<dd><p>从在 TOS 内找到的模块中加载属性 <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code>。 结果对象会被推入栈顶，以便由后续的 <a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a> 指令来保存。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-JUMP_FORWARD">
<code class="sig-name descname">JUMP_FORWARD</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-JUMP_FORWARD" title="永久链接至目标">¶</a></dt>
<dd><p>将字节码计数器的值增加 <em>delta</em>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-POP_JUMP_IF_TRUE">
<code class="sig-name descname">POP_JUMP_IF_TRUE</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-POP_JUMP_IF_TRUE" title="永久链接至目标">¶</a></dt>
<dd><p>如果 TOS 为真值，则将字节码计数器的值设为 <em>target</em>。 TOS 会被弹出。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.1 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-POP_JUMP_IF_FALSE">
<code class="sig-name descname">POP_JUMP_IF_FALSE</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-POP_JUMP_IF_FALSE" title="永久链接至目标">¶</a></dt>
<dd><p>如果 TOS 为假值，则将字节码计数器的值设为 <em>target</em>。 TOS 会被弹出。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.1 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-JUMP_IF_TRUE_OR_POP">
<code class="sig-name descname">JUMP_IF_TRUE_OR_POP</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-JUMP_IF_TRUE_OR_POP" title="永久链接至目标">¶</a></dt>
<dd><p>如果 TOS 为真值，则将字节码计数器的值设为 <em>target</em> 并将 TOS 留在栈顶。 否则（如 TOS 为假值），TOS 会被弹出。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.1 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-JUMP_IF_FALSE_OR_POP">
<code class="sig-name descname">JUMP_IF_FALSE_OR_POP</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-JUMP_IF_FALSE_OR_POP" title="永久链接至目标">¶</a></dt>
<dd><p>如果 TOS 为假值，则将字节码计数器的值设为 <em>target</em> 并将 TOS 留在栈顶。 否则（如 TOS 为假值），TOS 会被弹出。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.1 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-JUMP_ABSOLUTE">
<code class="sig-name descname">JUMP_ABSOLUTE</code><span class="sig-paren">(</span><em class="sig-param">target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-JUMP_ABSOLUTE" title="永久链接至目标">¶</a></dt>
<dd><p>将字节码计数器的值设为 <em>target</em>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-FOR_ITER">
<code class="sig-name descname">FOR_ITER</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-FOR_ITER" title="永久链接至目标">¶</a></dt>
<dd><p>TOS 是一个 <a class="reference internal" href="../glossary.html#term-iterator"><span class="xref std std-term">iterator</span></a>。 可调用它的 <a class="reference internal" href="stdtypes.html#iterator.__next__" title="iterator.__next__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__next__()</span></code></a> 方法。 如果产生了一个新值，则将其推入栈顶（将迭代器留在其下方）。 如果迭代器提示已耗尽则 TOS 会被弹出，并将字节码计数器的值增加 <em>delta</em>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_GLOBAL">
<code class="sig-name descname">LOAD_GLOBAL</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_GLOBAL" title="永久链接至目标">¶</a></dt>
<dd><p>加载名称为 <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code> 的全局对象推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_LOOP">
<code class="sig-name descname">SETUP_LOOP</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SETUP_LOOP" title="永久链接至目标">¶</a></dt>
<dd><p>Pushes a block for a loop onto the block stack.  The block spans from the
current instruction with a size of <em>delta</em> bytes.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_EXCEPT">
<code class="sig-name descname">SETUP_EXCEPT</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SETUP_EXCEPT" title="永久链接至目标">¶</a></dt>
<dd><p>Pushes a try block from a try-except clause onto the block stack. <em>delta</em>
points to the first except block.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-SETUP_FINALLY">
<code class="sig-name descname">SETUP_FINALLY</code><span class="sig-paren">(</span><em class="sig-param">delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SETUP_FINALLY" title="永久链接至目标">¶</a></dt>
<dd><p>Pushes a try block from a try-except clause onto the block stack. <em>delta</em>
points to the finally block.</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_FAST">
<code class="sig-name descname">LOAD_FAST</code><span class="sig-paren">(</span><em class="sig-param">var_num</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_FAST" title="永久链接至目标">¶</a></dt>
<dd><p>将指向局部对象 <code class="docutils literal notranslate"><span class="pre">co_varnames[var_num]</span></code> 的引用推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-STORE_FAST">
<code class="sig-name descname">STORE_FAST</code><span class="sig-paren">(</span><em class="sig-param">var_num</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_FAST" title="永久链接至目标">¶</a></dt>
<dd><p>将 TOS 存放到局部变量 <code class="docutils literal notranslate"><span class="pre">co_varnames[var_num]</span></code>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_FAST">
<code class="sig-name descname">DELETE_FAST</code><span class="sig-paren">(</span><em class="sig-param">var_num</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_FAST" title="永久链接至目标">¶</a></dt>
<dd><p>移除局部对象 <code class="docutils literal notranslate"><span class="pre">co_varnames[var_num]</span></code>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_CLOSURE">
<code class="sig-name descname">LOAD_CLOSURE</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_CLOSURE" title="永久链接至目标">¶</a></dt>
<dd><p>将一个包含在单元的第 <em>i</em> 个空位中的对单元的引用推入栈顶并释放可用的存储空间。 如果 <em>i</em> 小于 <em>co_cellvars</em> 的长度则变量的名称为 <code class="docutils literal notranslate"><span class="pre">co_cellvars[i]</span></code>。 否则为 <code class="docutils literal notranslate"><span class="pre">co_freevars[i</span> <span class="pre">-</span> <span class="pre">len(co_cellvars)]</span></code>。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_DEREF">
<code class="sig-name descname">LOAD_DEREF</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_DEREF" title="永久链接至目标">¶</a></dt>
<dd><p>加载包含在单元的第 <em>i</em> 个空位中的单元并释放可用的存储空间。 将一个对单元所包含对象的引用推入栈顶。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_CLASSDEREF">
<code class="sig-name descname">LOAD_CLASSDEREF</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_CLASSDEREF" title="永久链接至目标">¶</a></dt>
<dd><p>类似于 <a class="reference internal" href="#opcode-LOAD_DEREF"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LOAD_DEREF</span></code></a> 但在查询单元之前会首先检查局部对象字典。 这被用于加载类语句体中的自由变量。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.4 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-STORE_DEREF">
<code class="sig-name descname">STORE_DEREF</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_DEREF" title="永久链接至目标">¶</a></dt>
<dd><p>将 TOS 存放到包含在单元的第 <em>i</em> 个空位中的单元内并释放可用存储空间。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-DELETE_DEREF">
<code class="sig-name descname">DELETE_DEREF</code><span class="sig-paren">(</span><em class="sig-param">i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_DEREF" title="永久链接至目标">¶</a></dt>
<dd><p>清空包含在单元的第 <em>i</em> 个空位中的单元并释放可用存储空间。 被用于 <a class="reference internal" href="../reference/simple_stmts.html#del"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">del</span></code></a> 语句。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.2 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-RAISE_VARARGS">
<code class="sig-name descname">RAISE_VARARGS</code><span class="sig-paren">(</span><em class="sig-param">argc</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-RAISE_VARARGS" title="永久链接至目标">¶</a></dt>
<dd><p>使用 <code class="docutils literal notranslate"><span class="pre">raise</span></code> 语句的 3 种形式之一引发异常，具体形式取决于 <em>argc</em> 的值：</p>
<ul class="simple">
<li><p>0: <code class="docutils literal notranslate"><span class="pre">raise</span></code> (重新引发之前的异常)</p></li>
<li><p>1: <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">TOS</span></code> (在 <code class="docutils literal notranslate"><span class="pre">TOS</span></code> 上引发异常实例或类型)</p></li>
<li><p>2: <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">TOS1</span> <span class="pre">from</span> <span class="pre">TOS</span></code> (在 <code class="docutils literal notranslate"><span class="pre">TOS1</span></code> 上引发异常实例或类型并将 <code class="docutils literal notranslate"><span class="pre">__cause__</span></code> 设为 <code class="docutils literal notranslate"><span class="pre">TOS</span></code>)</p></li>
</ul>
</dd></dl>

<dl class="opcode">
<dt id="opcode-CALL_FUNCTION">
<code class="sig-name descname">CALL_FUNCTION</code><span class="sig-paren">(</span><em class="sig-param">argc</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CALL_FUNCTION" title="永久链接至目标">¶</a></dt>
<dd><p>调用一个可调用对象并传入位置参数。 <em>argc</em> 指明位置参数的数量。 栈顶包含位置参数，其中最右边的参数在最顶端。 在参数之下是一个待调用的可调用对象。 <code class="docutils literal notranslate"><span class="pre">CALL_FUNCTION</span></code> 会从栈中弹出所有参数以及可调用对象，附带这些参数调用该可调用对象，并将可调用对象所返回的返回值推入栈顶。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>此操作码仅用于附带位置参数的调用。</p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-CALL_FUNCTION_KW">
<code class="sig-name descname">CALL_FUNCTION_KW</code><span class="sig-paren">(</span><em class="sig-param">argc</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CALL_FUNCTION_KW" title="永久链接至目标">¶</a></dt>
<dd><p>调用一个可调用对象并传入位置参数（如果有的话）和关键字参数。 <em>argc</em> 指明位置参数和关键字参数的总数量。 栈顶元素包含一个关键字参数名称的元组。 在元组之下是根据元组排序的关键字参数。 在关键字参数之下是位置参数，其中最右边的参数在最顶端。 在参数之下是一个待调用的可调用对象。 <code class="docutils literal notranslate"><span class="pre">CALL_FUNCTION_KW</span></code> 会从栈中弹出所有参数以及可调用对象，附带这些参数调用该可调用对象，并将可调用对象所返回的返回值推入栈顶。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>关键字参数会被打包为一个元组而非字典，<em>argc</em> 指明参数的总数量。</p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-CALL_FUNCTION_EX">
<code class="sig-name descname">CALL_FUNCTION_EX</code><span class="sig-paren">(</span><em class="sig-param">flags</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CALL_FUNCTION_EX" title="永久链接至目标">¶</a></dt>
<dd><p>调用一个可调用对象并附带位置参数和关键字参数变量集合。 如果设置了 <em>flags</em> 的最低位，则栈顶包含一个由额外关键字参数组成的映射对象。 在该对象之下是一个包含位置参数的可迭代对象和一个待调用的可调用对象。 <a class="reference internal" href="#opcode-BUILD_MAP_UNPACK_WITH_CALL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_MAP_UNPACK_WITH_CALL</span></code></a> 和 <a class="reference internal" href="#opcode-BUILD_TUPLE_UNPACK_WITH_CALL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE_UNPACK_WITH_CALL</span></code></a> 可用于合并多个映射对象和包含参数的可迭代对象。  在该可调用对象被调用之前，映射对象和可迭代对象会被分别“解包”并将它们的内容分别作为关键字参数和位置参数传入。 <code class="docutils literal notranslate"><span class="pre">CALL_FUNCTION_EX</span></code> 会从栈中弹出所有参数以及可调用对象，附带这些参数调用该可调用对象，并将可调用对象所返回的返回值推入栈顶。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-LOAD_METHOD">
<code class="sig-name descname">LOAD_METHOD</code><span class="sig-paren">(</span><em class="sig-param">namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_METHOD" title="永久链接至目标">¶</a></dt>
<dd><p>从 TOS 对象加载一个名为 <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code> 的方法。 TOS 将被弹出。 此字节码可区分两种情况：如果 TOS 有一个名称正确的方法，字节码会将未绑定方法和 TOS 推入栈顶。 TOS 将在调用未绑定方法时被用作 <a class="reference internal" href="#opcode-CALL_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_METHOD</span></code></a> 的第一个参数 (<code class="docutils literal notranslate"><span class="pre">self</span></code>)。 否则会将 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 和属性查找所返回的对象推入栈顶。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-CALL_METHOD">
<code class="sig-name descname">CALL_METHOD</code><span class="sig-paren">(</span><em class="sig-param">argc</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CALL_METHOD" title="永久链接至目标">¶</a></dt>
<dd><p>调用一个方法。 <em>argc</em> 是位置参数的数量。 关键字参数不受支持。 此操作码被设计用于配合 <a class="reference internal" href="#opcode-LOAD_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LOAD_METHOD</span></code></a> 使用。 位置参数放在栈顶。 在它们之下放在栈中的是由 <a class="reference internal" href="#opcode-LOAD_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LOAD_METHOD</span></code></a> 所描述的两个条目（或者是 <code class="docutils literal notranslate"><span class="pre">self</span></code> 和一个未绑定方法对象，或者是 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 和一个任意可调用对象）。 它们会被全部弹出并将返回值推入栈顶。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-MAKE_FUNCTION">
<code class="sig-name descname">MAKE_FUNCTION</code><span class="sig-paren">(</span><em class="sig-param">flags</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-MAKE_FUNCTION" title="永久链接至目标">¶</a></dt>
<dd><p>将一个新函数对象推入栈顶。 从底端到顶端，如果参数带有指定的旗标值则所使用的栈必须由这些值组成。</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">0x01</span></code> 是一个默认值的元组，用于按位置排序的仅限位置形参以及位置或关键字形参</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">0x02</span></code> 是一个仅限关键字形参的默认值的字典</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">0x04</span></code> 是一个标注字典</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">0x08</span></code> 一个包含用于自由变量的单元的元组，生成一个闭包</p></li>
<li><p>与函数 (在 TOS1) 相关联的代码</p></li>
<li><p>函数的 <a class="reference internal" href="../glossary.html#term-qualified-name"><span class="xref std std-term">qualified name</span></a> (在 TOS)</p></li>
</ul>
</dd></dl>

<dl class="opcode">
<dt id="opcode-BUILD_SLICE">
<code class="sig-name descname">BUILD_SLICE</code><span class="sig-paren">(</span><em class="sig-param">argc</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_SLICE" title="永久链接至目标">¶</a></dt>
<dd><p id="index-0">将一个切片对象推入栈顶。 <em>argc</em> 必须为 2 或 3。 如果为 2，则推入 <code class="docutils literal notranslate"><span class="pre">slice(TOS1,</span> <span class="pre">TOS)</span></code>；如果为 3，则推入 <code class="docutils literal notranslate"><span class="pre">slice(TOS2,</span> <span class="pre">TOS1,</span> <span class="pre">TOS)</span></code>。 请参阅 <a class="reference internal" href="functions.html#slice" title="slice"><code class="xref py py-func docutils literal notranslate"><span class="pre">slice()</span></code></a> 内置函数了解详细信息。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-EXTENDED_ARG">
<code class="sig-name descname">EXTENDED_ARG</code><span class="sig-paren">(</span><em class="sig-param">ext</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-EXTENDED_ARG" title="永久链接至目标">¶</a></dt>
<dd><p>为任意带有大到无法放入默认的单字节的参数的操作码添加前缀。 <em>ext</em> 存放一个附加字节作为参数中的高比特位。 对于每个操作码，最多允许三个 <code class="docutils literal notranslate"><span class="pre">EXTENDED_ARG</span></code> 前缀，构成两字节到三字节的参数。</p>
</dd></dl>

<dl class="opcode">
<dt id="opcode-FORMAT_VALUE">
<code class="sig-name descname">FORMAT_VALUE</code><span class="sig-paren">(</span><em class="sig-param">flags</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-FORMAT_VALUE" title="永久链接至目标">¶</a></dt>
<dd><p>用于实现格式化字面值字符串（f-字符串）。 从栈中弹出一个可选的 <em>fmt_spec</em>，然后是一个必须的 <em>value</em>。 <em>flags</em> 的解读方式如下：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">(flags</span> <span class="pre">&amp;</span> <span class="pre">0x03)</span> <span class="pre">==</span> <span class="pre">0x00</span></code>: <em>value</em> 按原样格式化。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">(flags</span> <span class="pre">&amp;</span> <span class="pre">0x03)</span> <span class="pre">==</span> <span class="pre">0x01</span></code>: 在格式化 <em>value</em> 之前调用其 <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-func docutils literal notranslate"><span class="pre">str()</span></code></a>。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">(flags</span> <span class="pre">&amp;</span> <span class="pre">0x03)</span> <span class="pre">==</span> <span class="pre">0x02</span></code>: 在格式化 <em>value</em> 之前调用其 <a class="reference internal" href="functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a>。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">(flags</span> <span class="pre">&amp;</span> <span class="pre">0x03)</span> <span class="pre">==</span> <span class="pre">0x03</span></code>: 在格式化 <em>value</em> 之前调用其 <a class="reference internal" href="functions.html#ascii" title="ascii"><code class="xref py py-func docutils literal notranslate"><span class="pre">ascii()</span></code></a>。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">(flags</span> <span class="pre">&amp;</span> <span class="pre">0x04)</span> <span class="pre">==</span> <span class="pre">0x04</span></code>: 从栈中弹出 <em>fmt_spec</em> 并使用它，否则使用空的 <em>fmt_spec</em>。</p></li>
</ul>
<p>使用 <code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_Format()</span></code> 执行格式化。 结果会被推入栈顶。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.6 新版功能.</span></p>
</div>
</dd></dl>

<dl class="opcode">
<dt id="opcode-HAVE_ARGUMENT">
<code class="sig-name descname">HAVE_ARGUMENT</code><a class="headerlink" href="#opcode-HAVE_ARGUMENT" title="永久链接至目标">¶</a></dt>
<dd><p>这不是一个真正的操作码。 它用于标明使用参数和不使用参数的操作码 (分别为 <code class="docutils literal notranslate"><span class="pre">&lt;</span> <span class="pre">HAVE_ARGUMENT</span></code> 和 <code class="docutils literal notranslate"><span class="pre">&gt;=</span> <span class="pre">HAVE_ARGUMENT</span></code>) 之间的分隔线。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.6 版更改: </span>现在每条指令都带有参数，但操作码 <code class="docutils literal notranslate"><span class="pre">&lt;</span> <span class="pre">HAVE_ARGUMENT</span></code> 会忽略它。 之前仅限操作码 <code class="docutils literal notranslate"><span class="pre">&gt;=</span> <span class="pre">HAVE_ARGUMENT</span></code> 带有参数。</p>
</div>
</dd></dl>

</div>
<div class="section" id="opcode-collections">
<span id="id1"></span><h2>操作码集合<a class="headerlink" href="#opcode-collections" title="永久链接至标题">¶</a></h2>
<p>提供这些集合用于字节码指令的自动内省：</p>
<dl class="data">
<dt id="dis.opname">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">opname</code><a class="headerlink" href="#dis.opname" title="永久链接至目标">¶</a></dt>
<dd><p>操作名称序列，可使用字节码来索引。</p>
</dd></dl>

<dl class="data">
<dt id="dis.opmap">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">opmap</code><a class="headerlink" href="#dis.opmap" title="永久链接至目标">¶</a></dt>
<dd><p>映射操作名称到字节码的字典</p>
</dd></dl>

<dl class="data">
<dt id="dis.cmp_op">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">cmp_op</code><a class="headerlink" href="#dis.cmp_op" title="永久链接至目标">¶</a></dt>
<dd><p>所有比较操作名称的序列。</p>
</dd></dl>

<dl class="data">
<dt id="dis.hasconst">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hasconst</code><a class="headerlink" href="#dis.hasconst" title="永久链接至目标">¶</a></dt>
<dd><p>访问常量的字节码序列。</p>
</dd></dl>

<dl class="data">
<dt id="dis.hasfree">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hasfree</code><a class="headerlink" href="#dis.hasfree" title="永久链接至目标">¶</a></dt>
<dd><p>访问自由变量的字节码序列（请注意这里所说的‘自由’是指在当前作用域中被内部作用域所引用的名称，或在外部作用域中被此作用域所引用的名称。 它 <em>并不</em> 包括对全局或内置作用域的引用）。</p>
</dd></dl>

<dl class="data">
<dt id="dis.hasname">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hasname</code><a class="headerlink" href="#dis.hasname" title="永久链接至目标">¶</a></dt>
<dd><p>按名称访问属性的字节码序列</p>
</dd></dl>

<dl class="data">
<dt id="dis.hasjrel">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hasjrel</code><a class="headerlink" href="#dis.hasjrel" title="永久链接至目标">¶</a></dt>
<dd><p>具有相对跳转目标的字节码序列。</p>
</dd></dl>

<dl class="data">
<dt id="dis.hasjabs">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hasjabs</code><a class="headerlink" href="#dis.hasjabs" title="永久链接至目标">¶</a></dt>
<dd><p>具有绝对跳转目标的字节码序列。</p>
</dd></dl>

<dl class="data">
<dt id="dis.haslocal">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">haslocal</code><a class="headerlink" href="#dis.haslocal" title="永久链接至目标">¶</a></dt>
<dd><p>访问局部变量的字节码序列。</p>
</dd></dl>

<dl class="data">
<dt id="dis.hascompare">
<code class="sig-prename descclassname">dis.</code><code class="sig-name descname">hascompare</code><a class="headerlink" href="#dis.hascompare" title="永久链接至目标">¶</a></dt>
<dd><p>布尔运算的字节码序列</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">目录</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code> --- Python 字节码反汇编器</a><ul>
<li><a class="reference internal" href="#bytecode-analysis">字节码分析</a></li>
<li><a class="reference internal" href="#analysis-functions">分析函数</a></li>
<li><a class="reference internal" href="#python-bytecode-instructions">Python字节码说明</a></li>
<li><a class="reference internal" href="#opcode-collections">操作码集合</a></li>
</ul>
</li>
</ul>

  <h4>上一个主题</h4>
  <p class="topless"><a href="compileall.html"
                        title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> --- Byte-compile Python libraries</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="pickletools.html"
                        title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickletools</span></code> --- pickle 开发者工具集</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/dis.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="pickletools.html" title="pickletools --- pickle 开发者工具集"
             >下一页</a> |</li>
        <li class="right" >
          <a href="compileall.html" title="compileall --- Byte-compile Python libraries"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="language.html" >Python 语言服务</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2020, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 6月 29, 2020.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>2.3.1 创建。
    </div>

  </body>
</html>